package main

import (
    "github.com/gin-gonic/gin"
    "net/http"
)

func main() {
    r := gin.Default()
    r.Use(func(c *gin.Context) {
        passwd := c.Query("passwd")
        if passwd == "123456" {
            c.Next()
        } else {
            c.AbortWithStatusJSON(401, gin.H{"error": "passwd error"})
        }
    })
    r.GET("/hello", func(c *gin.Context) {
        name := c.Query("name")
        c.JSON(http.StatusOK, gin.H{
            "message": "fkxxyz",
            "name": name,
        })
    })
    r.Run()
}

